<?php

namespace App\Http\Requests\Operation;

use App\Http\Requests\Request;

class ContentTemplateTypeRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
 		switch($this->method())
        {
            case 'GET':
            case 'DELETE':
            {
                return [];
            }
            // Crate
            case 'POST':
            {
                return [
					'name' => 'required|max:100',
					'alias' => 'required|max:100',
					'listorder' => 'required',
                ];
            }
            // UPDATE
            case 'PUT':
            case 'PATCH':
            {
                // $contentTemplate = ContentTemplate::findOrFail($this->route('id'));
                return [
					'name' => 'required|max:100',
					'alias' => 'required|max:100',
					'listorder' => 'required',
                ];
            }
            default:
            	break;
        }
    }
    public function messages()
    {
        return [
            'name.required'       => '内容模板类型名称 不能为空',
            'name.max'       => '内容模板类型名称 不能大于 :100',
            'alias.max'     => '模板类型别名 不能大于 :100',
            'alias.required' => '模板类型别名 不能为空',
            'listorder.required' => '排序 不能为空',
            
        ];
    } 
}